package org.ycx.doc.dao.auto;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.ycx.doc.dao.model.DocProject;
import org.ycx.doc.dao.model.DocProjectExample;

public interface DocProjectMapper {
    @SelectProvider(type=DocProjectSqlProvider.class, method="countByExample")
    long countByExample(DocProjectExample example);

    @DeleteProvider(type=DocProjectSqlProvider.class, method="deleteByExample")
    int deleteByExample(DocProjectExample example);

    @Delete({
        "delete from doc_project",
        "where APP_ID = #{appId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer appId);

    @Insert({
        "insert into doc_project (APP_NAME, APP_DESC, ",
        "APP_PROD_VERSION, CREATE_TS, ",
        "CREATE_UID, UPDATE_TS, ",
        "UPDATE_UID)",
        "values (#{appName,jdbcType=VARCHAR}, #{appDesc,jdbcType=VARCHAR}, ",
        "#{appProdVersion,jdbcType=INTEGER}, #{createTs,jdbcType=DATE}, ",
        "#{createUid,jdbcType=INTEGER}, #{updateTs,jdbcType=DATE}, ",
        "#{updateUid,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="appId", before=false, resultType=Integer.class)
    int insert(DocProject record);

    @InsertProvider(type=DocProjectSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="appId", before=false, resultType=Integer.class)
    int insertSelective(DocProject record);

    @SelectProvider(type=DocProjectSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="APP_ID", property="appId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="APP_NAME", property="appName", jdbcType=JdbcType.VARCHAR),
        @Result(column="APP_DESC", property="appDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="APP_PROD_VERSION", property="appProdVersion", jdbcType=JdbcType.INTEGER),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER)
    })
    List<DocProject> selectByExample(DocProjectExample example);

    @Select({
        "select",
        "APP_ID, APP_NAME, APP_DESC, APP_PROD_VERSION, CREATE_TS, CREATE_UID, UPDATE_TS, ",
        "UPDATE_UID",
        "from doc_project",
        "where APP_ID = #{appId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="APP_ID", property="appId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="APP_NAME", property="appName", jdbcType=JdbcType.VARCHAR),
        @Result(column="APP_DESC", property="appDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="APP_PROD_VERSION", property="appProdVersion", jdbcType=JdbcType.INTEGER),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER)
    })
    DocProject selectByPrimaryKey(Integer appId);

    @UpdateProvider(type=DocProjectSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") DocProject record, @Param("example") DocProjectExample example);

    @UpdateProvider(type=DocProjectSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") DocProject record, @Param("example") DocProjectExample example);

    @UpdateProvider(type=DocProjectSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(DocProject record);

    @Update({
        "update doc_project",
        "set APP_NAME = #{appName,jdbcType=VARCHAR},",
          "APP_DESC = #{appDesc,jdbcType=VARCHAR},",
          "APP_PROD_VERSION = #{appProdVersion,jdbcType=INTEGER},",
          "CREATE_TS = #{createTs,jdbcType=DATE},",
          "CREATE_UID = #{createUid,jdbcType=INTEGER},",
          "UPDATE_TS = #{updateTs,jdbcType=DATE},",
          "UPDATE_UID = #{updateUid,jdbcType=INTEGER}",
        "where APP_ID = #{appId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(DocProject record);
}